package com.mz.ozy.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.MyShopBean;
import com.mz.ozy.utils.glideUtils.GlideUtils;

import java.util.List;

/**
 * @author lifeStyle on 2020/4/3 0003.
 */
public class CardListAdapter extends BaseQuickAdapter<MyShopBean.PageBean.PageItemsBean, BaseViewHolder> {

    public CardListAdapter(List<MyShopBean.PageBean.PageItemsBean> data) {
        super(R.layout.item_my_shop, data);

    }

    @Override
    protected void convert(BaseViewHolder helper, MyShopBean.PageBean.PageItemsBean item) {

        helper.addOnClickListener(R.id.btn_refund);
        ImageView ivIcon = helper.getView(R.id.iv_icon);
        if (item.getPrice().equals("0.00")) {
            helper.setText(R.id.tv_money, item.getMarket_price() + "积分");
        } else if (item.getMarket_price().equals("0.00")) {
            helper.setText(R.id.tv_money, "¥" + item.getPrice());
        } else if (!item.getMarket_price().equals("0.00") && !item.getPrice().equals("0.00")) {
            helper.setText(R.id.tv_money, "¥" + item.getPrice() + "+" + item.getMarket_price() + "积分");
        } else {
            helper.setText(R.id.tv_money, "");
        }

        helper.setText(R.id.tv_title, item.getTradename())
                .setText(R.id.tv_info, item.getDescribed());

        if (!TextUtils.isEmpty(item.getImg_zt())) {
            final String[] split = item.getImg_zt().split(",");
            GlideUtils.loadRoundImg(mContext, ivIcon, split[0], 5);
        } else {
            GlideUtils.loadRoundImg(mContext, ivIcon, R.mipmap.logo, 5);
        }


    }

}
